<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>下载页</title>
    <style>
        html,
        body {
            width: 100%;
            height: 100%;
            margin: 0;
        }

        .page {
            min-height: 100%;
        }

        .image {
            width: 100%;
        }
    </style>
</head>

<body>
    <div class="page">
        <img class="image" src="/static/home/share/img/1.gif">
    </div>
    <script>
        var query = window.location.search.substring(1);
        var href = 'hbuilder://m.benben.com?path=/pages/bargain/bargainDetail&' + query; // app本机地址
        var market_ios = 'market://details?id=io.dcloud.hellouniapp'; //app在安卓应用商店地址
        var market_android = 'itms-apps://itunes.apple.com/cn/app/hello-uni-app/id1417078253'; //app在苹果应用商店地址

        document.addEventListener('click', handleClick, false);

        function handleClick() {
            if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) {
                var loadDateTime = new Date();
                window.location = href;
                window.setTimeout(function () { //如果没有安装app,便会执行setTimeout跳转下载页
                    var timeOutDateTime = new Date();
                    if (timeOutDateTime - loadDateTime < 5000) {
                        window.location = market_ios; //ios下载地址  
                    } else {
                        window.close();
                    }
                }, 500);
            } else if (navigator.userAgent.match(/android/i)) {
                var state = null;
                try {
                    window.location = href; //schema链接或者universal link
                    window.setTimeout(function () {
                        window.location = market_android; //android下载地址  
                    }, 500);
                } catch (e) { }
            }
        }
    </script>

</body>

</html>